<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class model_state extends CI_Model{
    var $table      = "master_state";
    var $primary    = "state_id";
    
    public function __construct()
    {
        parent::__construct();
    }
    function get_all(){
        $q = $this->db->query("SELECT * FROM `".$this->table."`");
        return $q->result();
    }
    function save_data($isi){
        if( empty($isi) ) return false;
        if( $this->db->insert($this->table,$isi) ) return true;
        return false;
    }
    function update_data($id,$array){
        if(empty($id) || empty($array)) return FALSE;
        $this->db->where($this->primary,$id);	
        if($this->db->update($this->table,$array)) return TRUE;
        else return FALSE;
    }
    function delete($id){
        if( empty($id) ) return false;
        if($this->db->delete($this->table, array($this->primary => $id))) return true;
        else return false; 
    }
    function select_by_id($id,$mod = "result"){
        $q = $this->db->query("SELECT * FROM `$this->table` WHERE `".$this->primary."`='".$id."'");
        if(strtolower($mod) == "result") return $q->result();
        else return $q->num_rows();
    }
    
}
/* End of file model_state.php */
/* Location: ./application/models/model_state.php */
